package com.mav.controller;

import com.mav.pojo.Emp;
import com.mav.pojo.LoginInfo;
import com.mav.pojo.Result;
import com.mav.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RequestMapping("/login")
@RestController
public class LoginController {
    @Autowired
    EmpService empService;
    @PostMapping
    public Result login(@RequestBody Emp emp){
        log.info("登录信息:{}",emp);
        LoginInfo info=empService.getLoginInfo(emp);
        if(info!=null){
            return Result.success(info);
        }
        return Result.error("账号或密码错误");
    }
}
